home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cgazv5n5.arc
/
LIST7.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-23
|
1KB
|
48 lines
/*---------------------------------------- Listing 7 ------
* Demonstration of assert().
* See Listing 1 for copyright terms.
*-------------------------------------------------------*/
#include <stdio.h>
#include <signal.h>
/*---------------------------------------------------------
* If the following line is un-commented, assert will
* cease to function.
*-------------------------------------------------------*/
/* #define NDEBUG */
#include <assert.h>
void main ( void );
void Write ( FILE *Handle, char String[] );
void SigHndlr ( int Signal, int SubCode );
void main()
{
signal ( SIGABRT, SigHndlr );
/*---------------------------------------------------------
* Some poor soul doesn't understand Write()'s
* parameter requirements.
*-------------------------------------------------------*/
Write ( NULL, "Top of File\n" );
}
void Write ( FILE *Handle, char String[] )
{
/* Make sure we're getting valid parameters! */
assert ( String != NULL );
assert ( Handle != NULL );
fprintf ( Handle, "%s\n", String );
}
void SigHndlr ( int Signal, int SubCode )
{
fprintf ( stderr, "Signal %d, %d raised\n",
Signal, SubCode );
}